
/******************************************************************************
 *                  Shanghai ChipON Micro-Electronic Co.,Ltd
 ******************************************************************************
 *  @File Name        : kf8a100fxx_wdg.h
 *  @Author           : ChipON AE/FAE Group
 *  @Date             : 2023-12-19
 *  @HW Version       : KF8A100Fxx
 *  @Lib Version      : V2.0.1
 *  @Description      : This file provides the driver for the wdg module
 ******************************************************************************
 *  Copyright (C) by Shanghai ChipON Micro-Electronic Co.,Ltd
 *  All rights reserved.
 *
 *  This software is copyright protected and proprietary to
 *  Shanghai ChipON Micro-Electronic Co.,Ltd.
 *****************************************************************************/
/******************************************************************************
 *  |Date        |Version  |Author       |Description
 ******************************************************************************
 *  |2023-12-23  |V2.0     |Xiong Yichao |New creat
 *****************************************************************************/

#ifndef KF8A100FXX_WDG_H
#define KF8A100FXX_WDG_H

#ifdef __cplusplus
extern "C" {
#endif

/******************************************************************************
 *                      Include Files
 *****************************************************************************/
#include "kf8a100fxx.h"
/******************************************************************************
 *                      Macro or Inline
 *****************************************************************************/

/**
 * @brief wdg module disable/enable
 * 0: disable, 1:enable
 *
 */
#define WDG_ENABLE(x) (SWDTEN = (x))
/*****************************************************************************
 *                      Typedef Definitions
 *****************************************************************************/

/**
 * @brief WDT prescale
 */
typedef enum
{
    WDG_WDTPS_32    = 0u,
    WDG_WDTPS_64    = 1u,
    WDG_WDTPS_128   = 2u,
    WDG_WDTPS_256   = 3u,
    WDG_WDTPS_512   = 4u,
    WDG_WDTPS_1024  = 5u,
    WDG_WDTPS_2048  = 6u,
    WDG_WDTPS_4096  = 7u,
    WDG_WDTPS_8192  = 8u,
    WDG_WDTPS_16384 = 9u,
    WDG_WDTPS_32768 = 10u,
    WDG_WDTPS_65536 = 11u
} Wdg_WdtpsType;

/**
 * @brief WDG prescale
 */
typedef enum
{
    WDG_PS_1    = 0u,
    WDG_PS_2    = 1u,
    WDG_PS_4    = 2u,
    WDG_PS_8    = 3u,
    WDG_PS_16   = 4u,
    WDG_PS_32   = 5u,
    WDG_PS_64   = 6u,
    WDG_PS_128  = 7u,
    WDG_PS_NONE = 8u,
} Wdg_PsType;

/******************************************************************************
 *                      Export Variables
 *****************************************************************************/

/******************************************************************************
 *                      Export Functions
 *****************************************************************************/

/**
 * @brief WDG initialize TWDT = (2^(WDTPS+5)*2^(PS))/(31250)
 *
 * @param Pre WDG prescale
 * @param Div WDT div
 */
void Wdg_Init(Wdg_WdtpsType Pre, Wdg_PsType Div);

/**
 * @brief WDG deinitialization
 *
 */
void Wdg_DeInit(void);

/**
 * @brief watch dog enable, This function is invalid if WDG is turned on in the configuration word
 *
 */
void Wdg_Enable(void);

/**
 * @brief watch dog disable, This function is invalid if WDG is turned on in the configuration word
 *
 */
void Wdg_Disable(void);

/**
 * @brief feed watch dog
 *
 */
void Wdg_FeedDog(void);

#ifdef __cplusplus
}
#endif

#endif
/* EOF */
